home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DATATYPE.SWG / 0028_Re: SETS in basm.pas < prev   
Pascal/Delphi Source File  |  1995-02-28  |  1KB  |  50 lines

  1.  
  2. {set of char = array [1..32] of byte where each bit=1 if char is in set}
  3.  
  4. function aepos(const str:string; chs:charset; xst:byte):byte; assembler;
  5. asm
  6.         push ds
  7.         lds si,str
  8.         les di,chs
  9. @1:
  10.         mov bl,xst {xst is a copy of byte value , we can use it as i}
  11.         xor bh,bh
  12.         mov al,[si+bx] {str[i]}
  13.         mov ah,1
  14.         mov dx,32
  15.         call @BitMask {Input: al=char; Output: al=char mask, bx=chs offset}
  16.         test al,es:[di+bx] {str[i] in chs ?}
  17.         jnz @2 {yes}
  18.         mov al,xst {i}
  19.         cmp al,[si] {i>length(str) ?}
  20.         ja @2 {yes}
  21.         inc xst {i}
  22.         jmp @1
  23. @2:
  24.         mov al,xst
  25.         pop ds
  26.         jmp @exit
  27.  
  28. @BitMask:  {used ZBitMask from BP7 RTL ("seth.asm")}
  29.         mov ch,al
  30.         mov cl,3
  31.         shr ch,cl
  32.         sub ch,dh
  33.         jc @3
  34.         cmp ch,dl
  35.         jae @3
  36.         mov bl,ch
  37.         xor bh,bh
  38.         and al,7
  39.         mov cl,al
  40.         mov al,ah
  41.         rol al,cl
  42.         retn  {!}
  43. @3:
  44.         cwd
  45.         xchg dx,ax
  46.         xor bx,bx
  47.         retn  {!}
  48. @exit:
  49. end;
  50.